/*
 * Copyright (c) 2024 iSOFT INFRASTRUCTURE SOFTWARE CO., LTD.
 * easyAda is licensed under Mulan PubL v2.
 * You can use this software according to the terms and conditions of the Mulan PubL v2.
 * You may obtain a copy of Mulan PubL v2 at:
 *          http://license.coscl.org.cn/MulanPubL-2.0
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PubL v2 for more details.
 */

#ifndef MMAP_H_
#define MMAP_H_

#include <arch/mman-common.h>
#include <core/addrspace.h>
#include <core/task.h>

int do_map_region(addrspace_t *as, uint64_t des_va, uint64_t pa, uint64_t len, uint64_t prot, uint64_t flags);

unsigned long do_remap_region(uint64_t des_va, uint64_t src_va, uint64_t len, uint64_t prot, uint64_t flags);

void do_info_memory(page_table_t *cur_pg, int cur_level);

void check_va_attribute(page_table_t *pgtbl, uint64_t va);

uint64_t get_user_heap_addr(struct mm_struct *mm, uint64_t addr, uint64_t len);

int do_unmap_region(unsigned long addr, unsigned long len);

void add_vma_region(struct mm_struct *mm, uint64_t va_des, uint64_t va_heap, uint64_t pa, uint64_t size, uint64_t prot);

int remove_vma_region(struct mm_struct *mm, unsigned long va, unsigned long size);

int look_vma_region(struct mm_struct *mm, unsigned long va, unsigned long size);

void show_all_vma(struct mm_struct *mm);

void free_mmap_region(tcb_t *tcb);
#endif
